/*
 * Copyright (C) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef OHOS_MEDIALIBRARY_JSON_OPERATION_H
#define OHOS_MEDIALIBRARY_JSON_OPERATION_H

#include <string>
#include <vector>
#include <nlohmann/json.hpp>
#include <unordered_map>

#include "rdb_store.h"

namespace OHOS::Media {
class MediaJsonOperation {
public:
    static int32_t MapToJsonFile(
        const std::unordered_map<std::string, std::variant<int32_t, int64_t, std::string, double>> &externalMap,
        const std::vector<std::string> &columns, const std::string &outputPath);
    static bool CheckPathAndLoadJson(const std::string& jsonFilePath, nlohmann::json& outJsonData);
    static NativeRdb::ValuesBucket ReadJsonToValuesBucket(const std::string &jsonFilePath,
        const std::vector<std::string> &columns);

private:
    static void ParseAndPutKey(const std::string &key, const nlohmann::json &jsonData, const int memberType,
        NativeRdb::ValuesBucket &values);
    static bool IsValid(const nlohmann::json &jsonObj);
};
}  // namespace OHOS::Media
#endif  // OHOS_MEDIALIBRARY_JSON_OPERATION_H